<?php
class Builder{
	private $replaces;
	private $filename;
	function __construct($_filename) {
		$this->replaces = array();
		$this->filename = $_filename;
	}
	function addReplace($pattern, $replacement, $regularExpression=false){
		array_push($this->replaces,array($pattern, $replacement, $regularExpression));
	}
	function manipulate(){
		$content = file_get_contents($this->filename);
		foreach($this->replaces as $replace){
			if($replace[2]){
				$content = preg_replace($replace[0],$replace[1], $content);		
			} else {
				$content = str_replace($replace[0],$replace[1], $content);
			}
		}
		return $content;
	}
	function build($_filename){
		file_put_contents($_filename, $this->manipulate());
	}
}
?>